package com.levi.filter;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @author shentong
 * @since 2022/6/15 8:55 PM 过滤器应用场景
 *
 * 过滤敏感词汇（防止sql注入） 设置字符编码 URL级别的权限访问控制 压缩响应信息
 */
// @Component
@WebFilter("/testFilter")
@Slf4j
public class MyFilter implements Filter {

	@Override
	public void init(FilterConfig filterConfig) throws ServletException {
		log.info("Filter  初始化");
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
			throws IOException, ServletException {
		log.info("Filter  前置");
		filterChain.doFilter(request, response);
		log.info("Filter  后置");
	}

	@Override
	public void destroy() {
		log.info("Filter 销毁");
	}

}
